Materials/ Visual Shading Language/ Miscellaneous Examples

Miscellaneous Examples  

Clip mapping

Clip mapping is the effect where a material removes the underlying surface. The following example demonstrates this:

 

Notes:

The 'If' object test can be, for example, a test if the red signal is dark enough:

    X inside (0, 0.5)
    Y always
    Z always

Setting the 'Distance' channel to a negative value removes the surface. There is a VSL wizard available for clip mapping, as well as a template in the 'Image Maps' folder.

Example file: tutorprojects/material/vsl/clipmap
 
 

Simple glass

This is the structure of a very simple glass-like material:

 
 
Notes:

  • Color is set to black. This removes diffuse illumination, which would otherwise practically hide the transparency of the material.
  • Transparency is set to white (1,1,1). All light gets through the surface.
  • Refraction is defined by optical thickness channel, 0.1 is suitable for glass.

Example file: tutorprojects/material/vsl/simpleglass
 
 

Realistic glass

The glass material below is created by the Glass VSL wizard. It produces realistic looking glass.

 
Notes:

  • Glass color is defined as a constant, which is initialized in the 'Material initialization' shader. Other needed colors are consistently computed from this variable.
  • In the 'Surface properties' shader, transparency is defined as a function of the angle in which the ray hits the surface. Perpendicular rays penetrate the surface well, whereas rays that have the direction of the surface are reflected. The channel 'ray*normal' measures surface-ray angle: the channel value is +1 or -1 for orthogonal rays and approaches zero as the angle gets smaller.

 

Possible improvements:

If accurate reflectivity control is required, a curve object can be added to surface properties:

 
By adjusting the curve, surface reflectivity can be easily modified as a function of angle.

The 'Surface filtering' shader can be used to control the glass shadow creation. For example:

 
 
Here the difference '[subtract](light:distance, filter:distance)' measures the distance behind the glass. The curve object then adds some brightness according to this distance, so that there is actually a focal distance where the effect appears brightest. Finally, if the 3 curves that modify transparency are not identical, a colorful 'spectrum' shadow is created!

Example file: tutorprojects/material/vsl/spectralglass
 

Steel

In this example, the VSL structure of a metal created by the 'steel' wizard is examined;

 

Notes:

  • The 'Random' object that modifies the bump normal channel makes the surface appear rough. General/Normalize option should be set. The Random object's distribution should be zero-centered: base = -0.5*amplitude.
  • Reflections on the metal surface are faded by distance using a 'Secondary ray' shader. First, the distance of the reflection is modified by a simple linear transformation, then this value is squared to obtain faster, non-linear falloff rate for fading, and finally the color of reflection (found in traced ray:illumination) is divided by the value.

Example file: tutorprojects/material/vsl/steel

By replacing the 'Random 'object with a 'Noise' object, the rough appearance of the previous material can be changed to a 'brushed' metal appearance. The brush effect requires that the mapping used defines one dimension that is strongly compressed. The cylinder mapping axis is made very short for this purpose in the example project.

   
Example file: tutorprojects/material/vsl/brushedsteel
 

Texture mapped post processing particles

The color of particles can be defined using a VSL material:

  1. Create a set of 1D particles.
  2. Map the 'particle disks' post effect to the particles (use a default map).
  3. Map the following material to them with a parallel map:

 

Notes:

A 'Post particles' shader defines properties for particles that are rendered using a post effect such as Lens flare or Particle disks. Properties for 'Scan line' type particles are defined using a 'Surface properties' shader.

Example file: tutorprojects/material/vsl/texturedparticles
 
 

User defined VSL procedures

The program includes tools for creating new user defined VSL objects. Frequently needed algorithms can be collected into a VSL procedure library. The procedures can be called from VSL materials. For example:

  1. Create a new procedure library by using the menu 'New/VSL Procedure Library' of the material tab of the select window.
  2. Open the Properties window. The created procedure library contents are displayed.
  3. Drop a 'Procedure' object to the 'Root' node of the VSL tree.
  4. Select the created 'Procedure()' item. Rename it as 'Curvenoise' using the 'Name' field on the bottom of the VSL window.
  5. Change to the 'Parameters' tab and press 'Add'. A new parameter appears to the previously empty parameter list.
  6. Rename the parameter, for example, as 'cn_input' using the 'Parameter name' field.
  7. Drop a 'Noise' object to the 'Curvenoise' procedure. Change the input parameter of Noise to 'cn_input'.
    Output should be 'Return value'.
  8. Drop a 'Curve' object to the 'Curvenoise object'. Both output and input parameter should be 'Return value'.
    Modify the curve a bit.
     
  9. Now the procedure is ready. The structure is:

  10. Activate the select window and create a new VSL material. Set 'Advanced' option to see its contents on the property window.
  11. Drop a shader to the VSL tree of the new material. The default 'Surface properties' is suitable.
  12. Drop a 'Call' object to the surface properties shader and select it. Pick 'Curvenoise' from the displayed list of available procedures. The default input and output parameters are suitable. They can be changed using the VSL editor's popup menu.
  13.  

  14. Map the material to a test object using a parallel mapping and render.

Example file: tutorprojects/material/vsl/vslprocedure

 


Aluminium with blurred reflections

Customized ray tracing effects can be generated using the 'Raytrace' VSL object. The following aluminum like material generates strongly blurred reflections:

Blurring is created by a Raytrace object in a Surface finishing shader. The Raytrace object traces 5 random rays around the reflection direction. Each sample direction is strongly randomized. The rendered image shows how reflections remain recognizeable only at a very close range from the aluminium surface.

The image quality depends heavily on the amount of traced samples. It is easy to adjust the amount of traced rays, but high values should be used with care. If the scene contains aluminium surfaces that reflect each other, computation task (and hence rendering time) increases very rapidly when sampling rate grows. Already at a recursion depth 3 and sampling rate 10 one single aluminium surface evaluation can generate 10*10*10 = 1000 ray trace operations! Both recursion depth and recursion threshold should then be adjusted to keep the rendering time tolerable. The material itself can also define a local recursion limit: the 'Raytracer' object can be placed inside a 'If' level which tests that recursion depth is less than 1.01.

It is also possible to define a post processing configuration which filters away the noise of a shading component before adding it to the image. For details, see the example Post Processed Illumination.

Example file: tutorprojects/material/vsl/blurredaluminium